package com.corona.game;

import com.corona.Game;

/* compiled from: Battle.java */
/* access modifiers changed from: package-private */
/* loaded from: pokewilds.jar:com/pkmngen/game/DepleteEnemyHealth.class */
public class DepleteEnemyHealth extends Action {
    public Action.Layer layer;
    boolean firstStep;
    int timer;
    int removeNumber;
    int targetSize;
    int damage;

    public DepleteEnemyHealth(Game game, Action nextAction) {
        this(game, 0, nextAction);
    }

    public DepleteEnemyHealth(Game game, int damage, Action nextAction) {
        super(new Object[0]);
        this.layer = Action.Layer.gui_129;
        this.damage = 0;
        this.nextAction = nextAction;
        this.firstStep = true;
        this.timer = 3;
        this.removeNumber = 2;
        this.damage = damage;
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.firstStep) {
            if (this.damage > 0) {
                int currHealth = game.battle.oppPokemon.currentStats.get("hp").intValue();
                game.battle.oppPokemon.currentStats.put("hp", Integer.valueOf(currHealth - this.damage > 0 ? currHealth - this.damage : 0));
            }
            this.targetSize = (int) Math.ceil((double) ((((float) game.battle.oppPokemon.currentStats.get("hp").intValue()) * 48.0f) / ((float) game.battle.oppPokemon.maxStats.get("hp").intValue())));
            this.firstStep = false;
        }
        this.timer++;
        if (this.timer >= 4) {
            this.timer = 0;
            game.battle.drawAction.drawEnemyHealthAction.currHealth -= this.removeNumber;
            game.battle.drawAction.drawEnemyHealthAction.updateHealthBarColor();
            if (this.removeNumber == 2) {
                this.removeNumber = 1;
            } else {
                this.removeNumber = 2;
            }
            if (game.battle.drawAction.drawEnemyHealthAction.currHealth <= this.targetSize) {
                game.battle.drawAction.drawEnemyHealthAction.currHealth = this.targetSize;
                game.actionStack.remove(this);
                game.insertAction(this.nextAction);
            }
        }
    }
}
